# -*- coding: utf-8 -*-

__author__ = 'lcc@lavenliu.cn'

import os
import urllib.request


def link_baidu():
    url = 'http://www.baidu.com'
    try:
        resp = urllib.request.urlopen(url, timeout=3)
    except urllib.error.URLError:
        print(u'网络地址错误')
        os.exit(1)

    print('[resp.geturl()]: {}'.format(resp.geturl()))
    print('[resp.getcode()]: {}'.format(resp.getcode()))
    print('[resp.info()]:\n{}'.format(resp.info()))


if __name__ == '__main__':
    link_baidu()
